MyGame.s2 = function(game) {
	
	

};

MyGame.s2.prototype = {
    create: function() {
    	
        var that = this;

        this.oneAnimaite = true;

        this.change = false;



    	
		game.add.image(0,0,'s2_s3_bg');

        game.earth = game.add.image(game.world.centerX,game.world.centerY,'earth');
        game.earth.anchor.set(0.5,0.5);

        

        //game.camera.follow(game.earth);

        //game.world.setBounds(0, 0, game.world.width+3400, game.world.height+200);


        game.jizhanGroup = game.add.group()
       


        game.add.tween(game.earth.scale).to({x:2.5,y:2.5},1000,Phaser.Easing.Cubic.Out,true,1000)
        game.add.tween(game.earth).to({x:'+150',y:'+300'},1000,Phaser.Easing.Cubic.Out,true,1000).onComplete.add(this.jizhan,this)



        GameUI.cutscenes()
        

       

    },


    jizhan : function(){

        var that = this;

        var jz_pos = [
            {x:108,y:750},
            {x:108,y:750},
            {x:216,y:712},
            {x:263,y:825},
            {x:551,y:664},
            {x:361,y:796},
            {x:470,y:850},
            {x:500,y:774},
            {x:398,y:925}
        ]

        for(var i=0;i<jz_pos.length;i++){

            if(this.oneAnimaite){
                game.jizhan = game.add.image(jz_pos[i].x,jz_pos[i].y,'s2_jizhan');
                game.add.tween(game.jizhan).from({y:'-50',alpha:0},1000,Phaser.Easing.Cubic.Out,true,1000 + 100 * i)
            }

            console.log(i)

            if(i>=jz_pos.length-1){
                this.oneAnimaite = false;




            }

           

            console.log(this.oneAnimaite)

            

            
        }

        game.time.events.add(Phaser.Timer.SECOND * 4, function(){

            for(var i=0;i<jz_pos.length;i++){

                game.wifi = game.add.image(jz_pos[i].x-8,jz_pos[i].y-30,'wifi');
                game.add.tween(game.wifi).to({alpha:[0,0.8,0]},1000,Phaser.Easing.Cubic.Out,true,0,-1)

            }

            for(var i=0;i<jz_pos.length;i++){

                game.jz_5g = game.add.image(jz_pos[i].x,jz_pos[i].y+60,'jizhan_5g');
                game.add.tween(game.jz_5g).from({alpha:0},1000,Phaser.Easing.Cubic.Out,true,200)

            }

            game.time.events.add(Phaser.Timer.SECOND * 2, function(){

                loadChart('p2',function(){
                    $('#p2').hide();
                    setTimeout(function(){
                        $('#p2').find('.chat-content').css({
                            opacity : 1
                        })
                    },0)
                    that.scene_fadeOut()
                })

            })

            
           




            // loadChart('p2_1',function(){
            // 	$('#p2_1').hide();

            //     $('#p2_1').css({
            //         opacity : 0
            //     });

            //     GameUI.touch(378,816,function(){
            //         game.touch.kill()
            //         that.scene_fadeOut()
            //     });

            // })

        }, this);

    },

    scene_fadeOut : function(){
        this.change = true;
        GameUI.scenesfadeOut(2000,0)
    },

    update: function() {
    	
    	if(this.change){
            
            game.camera.scale.x += 0.01;
            game.camera.scale.y += 0.01;
            game.camera.x += 4;
            game.camera.y += 10;


            if(game.camera.scale.x >= 2.5){
                game.camera.scale.x = 1;
                game.camera.scale.y = 1;
                game.camera.x=0;
                game.camera.y=0;
                //game.world.setBounds(0, 0, game.world.width, game.world.height);
                game.state.start('s3')
            }

        }
    	
    },
    
    
    
    render : function(){
    	/*game.obstacles.forEach(function(item){
            game.debug.body(item);
        })
    	game.debug.body(game.player);*/
    }
};

